/**
 * @!type
 *  title 标题型
 *  prolist 省市列表
 *
 * @type {{ele: null, settings: {backgroundColor: string, opacity: string}, init: Function, init_edit: Function}}
 */
var diy_model = {
    ele: null,
    settings: {
        backgroundColor: '#000',
        opacity: '.4'
    },

    init: function (options) {
        if (options) {
            options = $.extend(this.settings, options);
            this.settings = options;
        }
        var head = jQuery('head');
        head.append('<link rel="stylesheet" type="text/css" href="'+URLPRE+'static/public/diy/diy.css" />');
        head.append('<link rel="stylesheet" type="text/css" href="'+URLPRE+'static/public/diy/form.css" />');
        head.append('<link rel="stylesheet" type="text/css" href="'+URLPRE+'static/public/Lib/artDialog/skins/default.css" />');
        head.append('<script type="text/javascript" src="'+URLPRE+'static/public/Lib/artDialog/jquery.artDialog.source.js"></script>');
        head.append('<script type="text/javascript" src="'+URLPRE+'static/public/Lib/artDialog/plugins/iframeTools.js"></script>');
    },

    edit: function (opt) {
        var pluginid = opt.pluginid;
        var obj = jQuery('#'+pluginid);
        var i = pluginid;

        obj.css({position: 'relative'});
        obj.prepend('<div class="diy-cover" id="c_'+i+'" style="display:none;background:'+this.settings.backgroundColor+';opacity:'+this.settings.opacity+'"></div>');

        obj.append('<div id="e_'+i+'" class="diy-edit">编辑</div>');
        jQuery('#e_'+i).hover(function(){
            jQuery('#c_'+i).show();
        }, function(){
            jQuery('#c_'+i).hide();
        });
        var diy = this;
        obj.find('div.diy-edit').on('click', function () {
            $.dialog.load(
                URLPRE+'diy/index/edit/?pluginid=' + pluginid + '&type=' + opt.type,
                {
                    title: 'DIY 位置：' + pluginid, padding: '', resize:true,
                    drag: true, width: '900px', fixed: true, zIndex: '100001', lock:false
                }
            );
            event.stopPropagation();
        });
    }
}